import fetch from 'common/src/utils/fetch';
// let apiPrefix = '/dev';
let apiPrefix = '/api/arrangementservice/';

/**
 *分页
 * @param data
 */
export function findPageList(data) {
  return fetch({
    url:  apiPrefix + 'teachingProgressConfig/page',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: data
  })
}

/**
 *新增
 * @param data
 */
export function addConfig(data) {
  return fetch({
    url:  apiPrefix + 'teachingProgressConfig/addTeachingProgressConfig',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: data
  })
}

/**
 * 修改
 * @param data
 */
export function updateConfig(data) {
  return fetch({
    url:  apiPrefix + 'teachingProgressConfig/updateTeachingProgressConfig',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: data
  })
}

/**
 *插入时学期学年唯一性校验
 */
export function checkIsExistCalendarId(data) {
  return fetch({
    url: apiPrefix + 'teachingProgressConfig/checkIsExistCalendarId',
    method: 'post',
    data:data
  })
}

/**
 * 删除
 */
export function deleteConfig(data) {
  return fetch({
    url: apiPrefix + 'teachingProgressConfig/deleteTeachingProgressConfig?id='+data,
    method: 'get'
  })
}

/**
 * 批量删除 注意传参
 * @param data
 */
export function deleteConfigList(idList) {
  return fetch({
    url:  apiPrefix + 'teachingProgressConfig/deleteConfigList',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data:{
      ids:idList
    }
  })
}

/**
 * 查询
 */
export function getConfigById(data) {
  return fetch({
    url: apiPrefix + 'teachingProgressConfig/getTeachingProgressConfigById?id='+data,
    method: 'get'
  })
}

/**
 * 当前学期学年设置
 * @param data
 */
export function getConfigByCalendarId(data,deptId) {
  return fetch({
    url: apiPrefix + 'teachingProgressConfig/getConfigByCalendarId?calendarId='+data+"&deptId="+deptId,
    method: 'get'
  })
}

/**
 * 初始化教学进度
 */
export function initProgressData(calendarId,deptId) {
  return fetch({
    url: apiPrefix + 'teachingProgressConfig/initProgressData?calendarId='+calendarId+"&deptId="+deptId,
    method: 'get',
    showMask: false
  })
}

  /**
   *设置控制方法
   * @param data
   */
export function checkTimeConfig(data) {
  return fetch({
    url:  apiPrefix + 'teachingProgressConfig/checkTimeConfig',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: data
  })
}
/**
 * 研究生控制方法 检查是否第一授课教师
 * @param {*} data 
 */
export function checkIsFirstTeacher(data) {
  return fetch({
    url:  apiPrefix + 'teachingProgressConfig/checkIsFirstTeacher',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: data
  })
}



export default {
   findPageList,
   checkIsExistCalendarId,
   getConfigByCalendarId,
   addConfig,
   updateConfig,
   deleteConfig,
   deleteConfigList,
   getConfigById,
   initProgressData,
   checkTimeConfig,
   checkIsFirstTeacher,
  // saveConfig,
  // findOnlyConfig
}


